package com.quectel.core.module.carparking.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.quectel.core.module.carparking.entity.CarParkingSpaceEntity;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author bobo
 * @email bob.yu@quectel.com
 * @date 2022/02/22 09:45
 */

public interface CarParkingSpaceDao extends BaseMapper<CarParkingSpaceEntity> {
    /**
     * 查询列表
     *
     * @param params
     * @return
     */
    List<CarParkingSpaceEntity> queryList(Map<String, Object> params);

    /**
     * 查询数量
     *
     * @param params
     * @return
     */
    int queryTotal(Map<String, Object> params);

    @Select("<script>select DISTINCT cps.*, pcm.join_time as lease_time from car_parking_space cps LEFT JOIN parking_card_member pcm on cps.id = pcm.car_parking_space_id where pcm.mobile = #{mobile}" +
            "</script>")
    List<CarParkingSpaceEntity> byCardLeased(@Param("mobile") String mobile);
}
